package com.fulin.thread.semaphore;

import java.util.concurrent.Semaphore;

public class Service {
	private Semaphore semaphore = new Semaphore(2);
	
	private int flag = 0;
	
	public void testMethod(){
		try {
			semaphore.acquire();
			this.flag ++ ;
			System.out.println(Thread.currentThread().getName() + " flag = "+this.flag);
			semaphore.release();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
